import { fetchJson } from "@/utils/fetch";
import { rootPath } from "@/configurations";
import { infoGetBaseInfo, personList } from "@/api";
export const mock = url => {
  return fetchJson(`${rootPath}${url}`).then(data => {
    return Promise.resolve({
      code: 200,
      msg: "成功",
      data
    });
  });
};
/**
 * @name 调用退出api
 */
export const loginOut = () => {
  return fetchJson(
    `https://xtbg.digitalgd.com.cn/zwrz/rz/sso/logout?client_id=zwrz_gzznywgl&backurl=https%3A%2F%2Fcmdb.gzopendata.com%2Fcmdb-admin%2Flogin`
  ).then(data => {
    return Promise.resolve({
      code: 200,
      msg: "成功",
      data
    });
  });
};
export const getIpAdress = url => {
  return fetchJson(`https://api.ipify.org?format=json`).then(data => {
    return Promise.resolve({
      code: 200,
      msg: "成功",
      data
    });
  });
};
export const getLabel = (
  type = "success",
  title = "标题",
  content = "0",
  unit = ""
) => {
  return { type, title, content, unit };
};
export const villageStatistic = () => {
  return new Promise(async (resolve, reject) => {
    try {
      resolve([
        getLabel("primary", "干线", "200", "条"),
        getLabel("success", "接入", "150", "条"),
        getLabel("danger", "专网", "40", "个"),
        getLabel("warning", "机房", "52", "个")
      ]);
    } catch (e) {
      reject(e);
    }
  });
};

export const jifangStatistic = () => {
  return new Promise(async (resolve, reject) => {
    try {
      resolve([
        getLabel("primary", "机房", "52", "个"),
        getLabel("success", "机柜", "872", "个"),
        getLabel("primary", "已出租", "568", "个"),
        getLabel("warning", "未出租", "304", "个")
      ]);
    } catch (e) {
      reject(e);
    }
  });
};

export const ganStatistic = () => {
  return new Promise(async (resolve, reject) => {
    try {
      resolve([
        getLabel("primary", "交换机", "320", "个"),
        getLabel("warning", "网络节点", "620", "个"),
        getLabel("success", "市骨干节点", "150", "个"),
        getLabel("primary", "主骨干节点", "52", "个")
      ]);
    } catch (e) {
      reject(e);
    }
  });
};

export const urls = () => {
  return mock("configs/urls.json");
};

export const outline = () => {
  return mock("configs/outline.json");
};

export const pipeline = () => {
  return mock("configs/textline.json");
};

export const tagList = () => {
  return mock("configs/tagList.json");
};

export const jsonList = () => {
  return mock("configs/json.json");
};

export const tagThemesList = () => {
  return mock("configs/tagThemes.json");
};

export const gzJson = () => {
  return mock("configs/gz_full.json");
};

export const getUrl = () => {
  return mock("url.json");
};

export const neicunList = () => {
  return mock("configs/neicun.json");
};

export const dkList = () => {
  return mock("configs/dk.json");
};
